2020-2021 Sunseeker Telemetry and Lighting System
dma_ex2_repeatedBlockUART.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
65 //******************************************************************************
66 
67 #include "driverlib.h"
68 
69 static char String1[] = { "Hello World\r\n" };
70 
71 void main (void)
72 {
73  //Stop Watchdog Timer
74  WDT_A_hold(WDT_A_BASE);
75 
76  //P3.4 = USCI_A0 TXD
77  GPIO_setAsPeripheralModuleFunctionInputPin(
78  GPIO_PORT_P3,
79  GPIO_PIN3
80  );
81 
82  USCI_A_UART_initParam param1 = {0};
83  param1.selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK;
84  param1.clockPrescalar = 6;
85  param1.firstModReg = 13;
86  param1.secondModReg = 0;
87  param1.parity = USCI_A_UART_NO_PARITY;
88  param1.msborLsbFirst = USCI_A_UART_LSB_FIRST;
89  param1.numberofStopBits = USCI_A_UART_ONE_STOP_BIT;
90  param1.uartMode = USCI_A_UART_MODE;
91  param1.overSampling = USCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;
92 
93  if (STATUS_FAIL == USCI_A_UART_init(USCI_A0_BASE, &param1)){
94  return;
95  }
96 
97  //Enable UART module for operation
98  USCI_A_UART_enable(USCI_A0_BASE);
99 
100 
101  //Initialize and Setup DMA Channel 0
102  /*
103  * Configure DMA channel 0
104  * Configure channel for repeated single transfers
105  * DMA interrupt flag will be set after every 12 transfers
106  * Use DMA Trigger Source 1 (TA0CCR0IFG)
107  * Transfer Byte-to-byte
108  * Trigger Upon Rising Edge of Trigger Source Signal
109  */
110  DMA_initParam param2 = {0};
111  param2.channelSelect = DMA_CHANNEL_0;
112  param2.transferModeSelect = DMA_TRANSFER_REPEATED_SINGLE;
113  param2.transferSize = (sizeof String1 - 1);
114  param2.triggerSourceSelect = DMA_TRIGGERSOURCE_1;
115  param2.transferUnitSelect = DMA_SIZE_SRCBYTE_DSTBYTE;
116  param2.triggerTypeSelect = DMA_TRIGGER_RISINGEDGE;
117  DMA_init(&param2);
118  /*
119  * Configure DMA channel 0
120  * Use String1 as source
121  * Increment source address after every transfer
122  */
123  DMA_setSrcAddress(DMA_CHANNEL_0,
124  (uint32_t)(uintptr_t)String1,
125  DMA_DIRECTION_INCREMENT);
126  /*
127  * Base Address of the DMA Module
128  * Configure DMA channel 0
129  * Use UART TX Buffer as destination
130  * Don't move the destination address after every transfer
131  */
132  DMA_setDstAddress(DMA_CHANNEL_0,
133  USCI_A_UART_getTransmitBufferAddressForDMA(USCI_A0_BASE),
134  DMA_DIRECTION_UNCHANGED);
135 
136  //Enable transfers on DMA channel 0
137  DMA_enableTransfers(DMA_CHANNEL_0);
138 
139  //For DMA0 trigger
140  Timer_A_initCompareModeParam initCompareModeParam = {0};
141  initCompareModeParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_2;
142  initCompareModeParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE;
143  initCompareModeParam.compareOutputMode = TIMER_A_OUTPUTMODE_OUTBITVALUE;
144  initCompareModeParam.compareValue = 1;
145  Timer_A_initCompareMode(TIMER_A0_BASE, &initCompareModeParam);
146 
147  //Timer sourced by SMCLK, starts in up-mode
148  Timer_A_initUpModeParam initUpModeParam = {0};
149  initUpModeParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
150  initUpModeParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
151  initUpModeParam.timerPeriod = 0x8192;
152  initUpModeParam.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE;
153  initUpModeParam.captureCompareInterruptEnable_CCR0_CCIE =
154  TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE;
155  initUpModeParam.timerClear = TIMER_A_SKIP_CLEAR;
156  initUpModeParam.startTimer = true;
157  Timer_A_initUpMode(TIMER_A0_BASE, &initUpModeParam);
158 
159 
160  //Enter LPM3
161  _BIS_SR(LPM3_bits);
162 }
163 
Timer_A_initUpModeParam initUpModeParam
void main(void)
#define STATUS_FAIL
Definition: hw_memmap.h:23